/*
作者：黄江南
目的：
信号处理函数执行时，进程收到了其他类型的洗好，interrupt()函数的执行就会被中断

注意：
同种信号使不能积累的

例如：
Interrupt called
^C^C^C^C^CInterrupt Func Ended.
Interrupt called
Interrupt Func Ended.
*/

#include <signal.h>
#include <stdio.h>

int interrupt()
{
    printf("Interrupt called\n");
    sleep(3);
    printf("Interrupt Func Ended.\n");
}

int main()
{
    signal(SIGINT, interrupt);
    printf("Interrupt set for SIGINT\n");
    sleep(10);
    printf("Program NORMAL ended.\n");
    return 1;
}